
import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useCounterStore = defineStore('menu', () => {
  const isCollapse = ref(false)
  const selectMenu = ref([])
  const menuActive = ref('1-1')
  // 菜单栏收缩
  const caidan = () => {
    isCollapse.value = !isCollapse.value
  }

  // 标签页的渲染
  const addMenu = (item) => {
    if (selectMenu.value.findIndex(item1 => item1.path === item.path) === -1){
      selectMenu.value.push(item)
    }
  }

  // 标签页的删除
  const removeMenu = (item) =>{
    selectMenu.value = selectMenu.value.filter(item1 => item1.name !== item)
  }


  // // 菜单的高亮
  // const menuActive1 = (item) => {
  //   localStorage.setItem('menuActive',item)
  //   menuActive.value =
  //   console.log(menuActive.value);

  //   menuActive.value = menuActive.value
  // }

  return {isCollapse, selectMenu, caidan, addMenu,removeMenu ,menuActive}
})
